var layer
function addLayerImage(option) {
	// console.log(placeNameService)
     layer = viewer.imageryLayers.addImageryProvider(
        // url+?service=WMTS&request=GetCapabilities 配置项
        new Cesium.UrlTemplateImageryProvider({
            //`${url}?layer=${layer}&style=default&tilematrixset=default028mm&Service=WMTS&Request=GetTile&Version=1.0.0&Format={format}&TileMatrix={TileMatrix}&TileRow={y}&TileCol={x}`
            url: `${option.wmtsUrl}?layer=RIVER_L&style=460203&tilematrixset=default028mm&Service=WMTS&Request=GetTile&Version=1.0.0&Format={format}&TileMatrix={TileMatrix}&TileRow={y}&TileCol={x}`,
            layer: option.layer,
            style: "default",
            format: "image/png",
            tileMatrixSetID: "default028mm",
            tilingScheme: new Cesium.GeographicTilingScheme(),
            //动态计算level
            customTags: {
                TileMatrix: function (imageryProvider, x, y, level) {
                    return level + 1;
                },
                // TileRow:function(y){
                //    return y+3000;
                // }
            },
        }));
        layer.name = option.name
    return  layer
}
function removeLayerByName(name) {
    for(var i =0;i<viewer.imageryLayers._layers.length;i++){
        if(name == viewer.imageryLayers._layers[i].name){
            viewer.imageryLayers.remove(viewer.imageryLayers._layers[i])
        }
    }
}
export {
    addLayerImage,
    removeLayerByName,
}